#include <iostream>
#include <vector>
#include <array>

void test_vector();
void test_array();

int main_container()
{
    // test_vector();
    // test_array();
    return 0;
}

void test_map() {
    
}

void test_vector() {
    using namespace std;
    vector<int> v1;
    v1.push_back(10);
    v1.push_back(20);
    v1.push_back(30);
    v1.push_back(40);
    cout << "第2个数据是:" << v1.at(1) << endl;
    cout << "Use for to iterator: " << endl;
    for(auto &v : v1) {
        cout << "value: " << v << endl; 
    }

    cout << "Use iterator: " << endl;
    for(vector<int>::iterator it = v1.begin(); it != v1.end(); it ++) {
        cout <<"第" << it - v1.begin() << "个数据是: " << *it << endl;
    }
}

void test_array()
{
    typedef std::array<int, 4> MyArray;
    MyArray array0 = {10, 11, 12};
    array0[3] = 40;
    using namespace std;
    cout << "使用for遍历array" << endl;
    for(const auto &it: array0) {
        std::cout << " " << it << std::endl;
    }
    cout << "使用for size()遍历array" << endl;
    for (size_t i = 0; i < array0.size(); i++)
    {
        std::cout << "第" << i << "个数据是:" << array0.at(i) << std::endl;
    }
    cout << "使用const_iterator遍历array" << endl;
    for (MyArray::const_iterator it = array0.begin(); it != array0.end(); it++)
    {
        std::cout << "iterator:" << it - array0.begin() << *it << std::endl;
    }
}

